# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=rime-cangjie
pkgver=0.0.0.20210223
_commit=8dfad9e537f18821b71ba28773315d9c670ae245
pkgrel=1
pkgdesc="Cangjie input for rime"
arch=('loong64' 'x86_64')
url="https://github.com/rime/rime-cangjie"
license=('LGPL')
# dependency for reverse lookup
depends=('rime-luna-pinyin')
makedepends=('librime' 'rime-prelude' 'rime-essay')
source=("https://github.com/rime/rime-cangjie/archive/$_commit/rime-cangjie-$_commit.tar.gz")
sha512sums=('48e505227b13c03610fc5d0e25125b5b5aff73fa051bab2a8a408d08391f8416f3010154355d0a80cdc841825d362352bb85efd8fd4d038680c4c835b060ca0a')

prepare() {
  cd $pkgname-$_commit
  # Link essentials
  for _f in $(pacman -Qql rime-prelude rime-essay | grep -v "/$"); do ln -sf $_f; done
}

build(){
  cd $pkgname-$_commit
  for _s in $(ls *.schema.yaml); do rime_deployer --compile $_s; done
}

package() {
  cd $pkgname-$_commit
  find . -type l -delete
  rm build/*.txt
  install -Dm644 *.yaml -t "$pkgdir"/usr/share/rime-data/
  install -Dm644 build/* -t "$pkgdir"/usr/share/rime-data/build/
}
